<?php


namespace App\Http\Controllers\Admin\Api;


use App\Http\Controllers\Controller;
use App\Http\Repositories\Services\IBrand;
use App\Http\Requests\Admin\BrandInputDTO;
use App\Util\ResultsVo;

class BrandController extends Controller
{
    protected $brandService;

    public function __construct(IBrand $brandService)
    {
        $this->brandService = $brandService;
    }

    public function page()
    {
        $data = $this->brandService->getAll();
        return response()->json(new ResultsVo(['data' => $data]));
    }

    public function tree($id){
        $data = $this->brandService->getParentId($id);
        return response()->json(new ResultsVo(['data' => $data]));
    }

    public function show($id)
    {
        $data = $this->brandService->byId($id);
        return response()->json(new ResultsVo(['data' => $data]));
    }

    public function store(BrandInputDTO $inputDTO)
    {
        $this->brandService->store($inputDTO);
        return response()->json(new ResultsVo(['message' => __('response.success')]));
    }

    public function update(BrandInputDTO $inputDTO, $id)
    {
        $this->brandService->update($inputDTO, $id);
        return response()->json(new ResultsVo(['message' => __('response.success')]));
    }

    public function delete($id)
    {
        $this->brandService->delete($id);
        return response()->json(new ResultsVo(['message' => __('response.success')]));
    }
}